package com.kl.forum.service;

import com.kl.forum.dao.ArticleCollectMapper;
import com.kl.forum.entity.ArticleCollect;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class ArticleCollectService {
    @Autowired
    private ArticleCollectMapper articleCollectMapper;

    public ArticleCollect findOne(Integer userId,Integer articleId){
        Map map =new HashMap();
        map.put("userId",userId);
        map.put("articleId",articleId);
        return articleCollectMapper.findOne(map);
    }
    public int addArticleCollect(Integer userId,Integer articleId){
        ArticleCollect articleCollect=new ArticleCollect();
        articleCollect.setUserId(userId);
        articleCollect.setArticleId(articleId);
        articleCollect.setCreateTime(new Date());
        articleCollect.setStatus(1);
       return articleCollectMapper.insertSelective(articleCollect);
    }
    public  int update(ArticleCollect articleCollect){
        return articleCollectMapper.updateByPrimaryKeySelective(articleCollect);
    }

}
